package com.vitogiovanni.tobook.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.vitogiovanni.tobook.entity.LocaleEndpoint;
import com.vitogiovanni.tobook.entity.Menu;

/**
 * Servlet implementation class InvitaLavoroServlet
 */
public class InserisciMenuServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public InserisciMenuServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

	}

	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		LocaleEndpoint localeEndpoint = new LocaleEndpoint();
		Menu menu = new Menu();
		
		String menuNome = req.getParameter("nome");
		String nomeLocale = req.getParameter("nomeLocale");
		
		menu.setNome(menuNome);
		localeEndpoint.insertMenu(menu, nomeLocale);
	
		resp.sendRedirect("/inserimento.html");
	
	}
}